package com.code.zg.news.views.activity;

import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.code.zg.news.R;
import com.code.zg.news.base.BaseActivity;
import com.code.zg.news.model.bean.WelcomeBean;
import com.code.zg.news.presenters.contracts.WelcomeContract;
import com.code.zg.news.presenters.presenter.WelcomePresenter;
import com.code.zg.news.utils.ImageLoader;

import butterknife.BindView;

public class WelcomeActivity extends BaseActivity<WelcomePresenter> implements WelcomeContract.View {
    @BindView(R.id.iv_welcome_bg)
    ImageView ivWelcomeBg;
    @BindView(R.id.tv_welcome_author)
    TextView tvWelcomeAuthor;
    @Override
    protected int getLayout() {
        return R.layout.activity_welcome;
    }

    @Override
    protected void initInject() {
        getAtivityComponent().inject(this);
    }

    @Override
    protected void initEventAndData() {
        mPresenter.getWelcomeData();

    }

    @Override
    public void jumpToMain() {
        Intent intent=new Intent(mContext,MainActivity.class);
        startActivity(intent);
        overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
        finish();


    }

    @Override
    public void showContent(WelcomeBean bean) {
        ImageLoader.load(this,bean.img,ivWelcomeBg);
        tvWelcomeAuthor.setText(bean.text);
        ivWelcomeBg.animate().scaleX(1.12f).scaleY(1.12f).setDuration(2000).setStartDelay(100).start();

    }

    @Override
    public void showError(String msg) {

    }

    @Override
    protected void onDestroy() {
        Glide.clear(ivWelcomeBg);
        super.onDestroy();

    }
}
